package main

import "fmt"

type Pay interface {
	DoPay(price int64) string
}

type AliPay struct{}

type WechatPay struct{}

type YinLianPay struct{}

func (m *AliPay) DoPay(price int64) string {
	return "支付宝支付"
}

func (m *WechatPay) DoPay(price int64) string {
	return "微信支付"
}

func (m *YinLianPay) DoPay(price int64) string {
	return "银联支付"
}

type PayFactory interface {
	CreatePay() Pay
}

type AliPayFactory struct{}

type WechatPayFactory struct{}

type YinLianPayFactory struct{}

func (m *AliPayFactory) CreatePay() Pay {
	return &AliPay{}
}

func (m *WechatPayFactory) CreatePay() Pay {
	return &WechatPay{}
}

func (m *YinLianPayFactory) CreatePay() Pay {
	return &YinLianPay{}
}

func main() {
	aliPayFactory := &AliPayFactory{}
	pay := aliPayFactory.CreatePay()
	fmt.Println(pay.DoPay(100))

	wechatPayFacotry := &WechatPayFactory{}
	pay = wechatPayFacotry.CreatePay()
	fmt.Println(pay.DoPay(200))

	yinLianPayFactory := &YinLianPayFactory{}
	pay = yinLianPayFactory.CreatePay()
	fmt.Println(pay.DoPay(300))
}
